package com.conan.utils;

@SuppressWarnings("all")
public class ThreadLocalUtil {
    private static final ThreadLocal THREAD_LOCAL = new ThreadLocal();
    //根据键获取值
    public static<T> T get() {
        return (T) THREAD_LOCAL.get();
    }
    //存储键值对
    public static void set(Object value){
        THREAD_LOCAL.set(value);
    }
    //清除ThreadLocal，防止内存泄漏
    //ThreadLocal对象是全局唯一的，生命周期特别长，如果里面的数据一直不清除，有可能造成内存泄漏
    public static void remove(){
        THREAD_LOCAL.remove();
    }
}
